﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Configuration;
using System.Runtime.Remoting;
using SalonPay.BLL;
using System.Threading;
using System.IO;
namespace SalonPay.Service
{
    public partial class Service1 : ServiceBase
    {
        public Service1()
        {
            InitializeComponent();
        }       

        public string fileName = "";
        public string clubs = "";
        protected override void OnStart(string[] args)
        {
            try
            {
                Thread.Sleep(3000);
                fileName = AppDomain.CurrentDomain.BaseDirectory + ConfigurationManager.AppSettings["ConfigFileName"];
                clubs = AppDomain.CurrentDomain.BaseDirectory + ConfigurationManager.AppSettings["ClubConfig"];
                RemotingConfiguration.Configure(fileName, false);
                MessageTypeHandler msg = new MessageTypeHandler();
                if (clubs == "clubc")
                    ClubCSocket.SNetMsg_RegUserLogin(msg);
                else
                    GameSocketConn.SNetMsg_RegUserLogin(msg);
            }
            catch (IOException ex)
            {
                return;
            }
        }  

        protected override void OnStop()
        {
            // TODO: 在此处添加代码以执行停止服务所需的关闭操作。

            GameSocketConn.OnTcpClientStop();
            GameSocketConn.OnThreadStop();
        }
    }
}
